<template>
  <xdh-echarts :options="options" width="100%" height="88%"></xdh-echarts>
</template>

<script>
  import XdhEcharts from '../widgets/xdh-echarts'
  import echarts from 'echarts'

  export default {
    name: 'pictorial-bar',
    components: {
      XdhEcharts
    },
    directives: {},
    props: {
      seriesData: {
        type: Array,
        default() {
          return []
        }
      },
      // X轴坐标
      xAxisData: {
        type: Array,
        default() {
          return []
        }
      }
    },
    mixins: [],
    data() {
      let pathSymbols = {
        doctor: 'image://' + require('../assets/bigscreen/icon_man1.png'),
        master: 'image://' + require('../assets/bigscreen/icon_man2.png'),
        bachelor: 'image://' + require('../assets/bigscreen/icon_man3.png'),
        other: 'image://' + require('../assets/bigscreen/icon_man4.png')
      }
      const COLOR = ['#12c6c8', '#e1cc0f', '#5083ff', '#e54035']
      return {
        options: {
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'none'
            },
            formatter: function (params) {
              return params[0].name + ': ' + params[0].value;
            }
          },
          grid: {
            show: true,
            top: '20%',
            left: '18%',
            right: '18%',
            bottom: '20%',
            borderWidth: 0,
            backgroundColor: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [
                {offset: 0, color: 'transparent'},
                {offset: 1, color: 'rgba(18, 198, 200, 0.1)'}
              ]
            )
          },
          xAxis: {
            type: 'category',
            data: this.xAxisData,
            axisTick: {show: false},
            axisLine: {show: false},
            axisLabel: {
              textStyle: {
                color: '#fff'
              }
            }
          },
          yAxis: {
            splitLine: {show: false},
            axisTick: {show: false},
            axisLine: {show: false},
            axisLabel: {show: false}
          },
          color: COLOR,
          series: [{
            name: 'hill',
            type: 'pictorialBar',
            barCategoryGap: '-100%',
            symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
            itemStyle: {
              normal: {
                color: (params) => {
                  return COLOR[params.dataIndex]
                },
                opacity: 0.5
              },
              emphasis: {
                opacity: 1
              }
            },
            data: this.seriesData,
            z: 10
          }, {
            name: 'glyph',
            type: 'pictorialBar',
            barGap: '-100%',
            symbolPosition: 'end',
            symbolSize: 50,
            symbolOffset: [0, '-80%'],
            data: [{
              value: this.seriesData[0],
              symbol: pathSymbols.doctor,
              symbolSize: [50, 60]
            }, {
              value: this.seriesData[1],
              symbol: pathSymbols.master,
              symbolSize: [50, 60]
            }, {
              value: this.seriesData[2],
              symbol: pathSymbols.bachelor,
              symbolSize: [50, 60]
            }, {
              value: this.seriesData[3],
              symbol: pathSymbols.other,
              symbolSize: [50, 60]
            }]
          }]
        }
      }
    },
    computed: {},
    watch: {},
    methods: {},
    created() {
    }
  }
</script>

<style scoped>

</style>
